﻿using EA.BA;
using EA.Common;
using EA.DTO;
using EAWebAdmin.template;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace EAAdmin
{
    public partial class ViewProductCategory : WebPage
    {
        override
        protected void Load(object sender, EventArgs e)
        {
            ProductCategoryBA productCategoryBA = new ProductCategoryBA();
            List<ProductCategoryTO> listProductCategory = productCategoryBA.GetAllProductCategory();
            Attributes.Add("listProductCategory", listProductCategory);
        }

        public void Delete(HttpRequest request,HttpResponse response)
        {

            if (Request["id"] != null && StringUtil.IsPositiveNumber(Request["id"]))
            {
                int deleteID = Convert.ToInt32(Request["id"]);
                ProductCategoryBA productCategoryBA = new ProductCategoryBA();
                Boolean stt = productCategoryBA.DeleteProductCategory(deleteID, Constant.PRODUCT_CATEGORY_DELETE);
                if (!stt == true)
                {
                    Attributes.Add("err", "Delete faulty");
                }
                else
                {
                    Attributes.Add("success", "Delete successfully");  
                }
                this.isLoad = true;
            }
        }

    }
}